#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>


int main()
{
    pid_t pid=fork();
    if(pid==0)
    {
        //子进程
        int cn =20;
        while(cn--)
        {
            printf("我是子进程，pid:%d\n",getpid());
            sleep(1);
        }
        printf("子进程退出\n");
        exit(1);
    }
    //父进程
    int cnt =5;
    while(cnt--)
    {
        printf("我是父进程，pid:%d\n",getpid());
        sleep(1);
    }
    return 0;
}
